/**
 * 
 */

package com.wutianyi.mvc.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

/**
 * @author wutianyi
 * 
 */
@Controller
@SessionAttributes("list")
public class JqueryController {

	@ModelAttribute("pet")
	public List<String> initList() {

		List<String> list = new ArrayList<String>();
		for(int i = 0; i < 10; i++) {
			list.add("test_" + i);
		}
		System.out.println(list);
		return list;
	}

	@RequestMapping(value = "/initPage.html")
	public String initPage(@ModelAttribute("pet") List<String> list, HttpServletRequest request, HttpServletResponse response) {
		System.out.println(list);
		request.setAttribute("list", list);
		
		return "list";
	}

	public JqueryController() {

		// 获取绑定的applicationContext
		// ApplicationContext applicationContext =
		// RequestContextUtils.getWebApplicationContext(null);
	}
}
